/**
 * Created by udi on 2016/11/24.
 */
var gulp = require('gulp');
var babel = require('gulp-babel');
var sourcemaps = require("gulp-sourcemaps");

var es7Sources = ["main/*.js", "libs/**/*.js", "mvc/**/*.js"];

var es7Js = {
  "main/**.js": "bin/main",
  "libs/**/*.js": "bin/libs",
  "mvc/**/*.js": "bin/mvc"
};

gulp.task('babelify', function () {
  for (let f  in es7Js) {
    gulp.src(f)
      .pipe(babel({
        presets: ['es2015', 'es2016', 'es2017'],
        plugins: [["transform-runtime", {
          "polyfill": false,
          "regenerator": true
        }]]
      }))
      .pipe(gulp.dest(es7Js[f]))
      .on('error', function (err) {
        console.log(err.stack);
        this.emit('end');
      })
  }
});

// gulp.task('minifycss', function() {
//   let publicFilter = ["res/*min.css"];
//   return gulp.src('res/**.css')      //压缩的文件
//     .pipe(  publicFilter)
//     .pipe(gulp.dest('minified/css'))   //输出文件夹
//     .pipe(minifycss());   //执行压缩
// });

gulp.task('watch', function () {
  return gulp.watch(es7Sources, ['babelify']);
});

gulp.task('default', ['babelify', 'watch']);

